package com.qf.common.core.utils;

/**
 * --- 天道酬勤 ---
 *
 * @author QiuShiju
 * @date 2025/11/6
 * @desc 封装了ThreadLocal,形成工具类,可以方便直接调用存储,获取 uid
 */
public class UserUtils {

    private static ThreadLocal<Integer> threadLocal = new ThreadLocal<>();

    public static void setUid(Integer uid){
        // Thread thread = Thread.currentThread();
        // String name = thread.getName();
        // long id = thread.getId();
        // int hashcode = threadLocal.hashCode();
        // String s = String.format("当前线程名: %s , 线程id: %s , 使用的threadLocal的对象地址: %s", name, id,hashcode);
        // System.out.println(s);
        threadLocal.set(uid);
    }

    public static Integer getUid(){
        return threadLocal.get();
    }

    public void remove(){
        threadLocal.remove();
    }
}
